//
//  XJ_ApplicationDetailViewController.m
//  XunJieProject
//
//  Created by 薛子 on 2018/6/11.
//  Copyright © 2018年 Soowin. All rights reserved.
//

#import "XJ_ApplicationDetailViewController.h"

@interface XJ_ApplicationDetailViewController ()<UIWebViewDelegate>

@end

@implementation XJ_ApplicationDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.nav_titleLabel.text = @"推广";
    
    if (_isAddCard == YES) {
        
         self.nav_titleLabel.text = @"添加信用卡";
    }
    
    UIWebView * webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, SafeAreaTopHeight, SCREEN_WIDTH, SCREEN_HEIGHT - SafeAreaTopHeight)];
    webView.delegate = self;
    
    if (_isProtocal == YES) {

        self.nav_titleLabel.text = @"注册协议";
        self.view.backgroundColor = [UIColor whiteColor];
        
        webView.frame = CGRectMake(15, SafeAreaTopHeight+20, SCREEN_WIDTH-30, SCREEN_HEIGHT - SafeAreaTopHeight - 40);
        NSString *path = [[NSBundle mainBundle] pathForResource:@"about" ofType:@"html"];
        NSURL* url = [NSURL fileURLWithPath:path];
        //创建URL
        NSURLRequest* request = [NSURLRequest requestWithURL:url];//创建NSURLRequest
        [webView loadRequest:request];

        //自动适应大小
//        webView.scalesPageToFit = YES;
        
        //关闭下拉刷新效果
        webView.scrollView.bounces = NO;
        
    }else{
        
        NSURL *url = [NSURL URLWithString:_urlString];//创建URL
        NSURLRequest* request = [NSURLRequest requestWithURL:url];//创建
        [webView loadRequest:request];//加载
    }
    
    [self.view addSubview:webView];
    

    // Do any additional setup after loading the view.
}

-(void)loadDocument:(NSString *)documentName inView:(UIWebView *)webView {
    NSString *path = [[NSBundle mainBundle] pathForResource:documentName ofType:nil];
    NSURL *url = [NSURL fileURLWithPath:path];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [webView loadRequest:request];
    
}

//开始加载网页
- (void)webViewDidStartLoad:(UIWebView *)webView{
    
    
}
//网页加载完成
- (void)webViewDidFinishLoad:(UIWebView *)webView{
    
}
//网页加载错误
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)backButtonClick{
    
    if (_isAddCard == YES) {
        
        [self.navigationController popToRootViewControllerAnimated:YES];
    }else{
        [self.navigationController popViewControllerAnimated:YES];
    }
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
